package logger

import "context"

var DefaultLogger Logger

func InitLogger(l Logger) {
	DefaultLogger = l
}

type Fields map[string]interface{}

type Logger interface {
	WithField(key string, value interface{}) Logger
	WithFields(fields Fields) Logger
	WithContext(ctx context.Context) Logger
	Trace(args ...interface{})
	Tracef(format string, args ...interface{})
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

func WithContext(ctx context.Context) Logger {
	return DefaultLogger.WithContext(ctx)
}
func WithField(key string, value interface{}) Logger {
	return DefaultLogger.WithField(key, value)
}

func WithFields(fields Fields) Logger {
	return DefaultLogger.WithFields(fields)
}

func Trace(args ...interface{}) {
	DefaultLogger.Trace(args...)
}
func Tracef(format string, args ...interface{}) {
	DefaultLogger.Tracef(format, args...)
}
func Debug(args ...interface{}) {
	DefaultLogger.Debug(args...)
}
func Debugf(format string, args ...interface{}) {
	DefaultLogger.Debugf(format, args...)
}
func Info(args ...interface{}) {
	DefaultLogger.Info(args...)
}
func Infof(format string, args ...interface{}) {
	DefaultLogger.Infof(format, args...)
}
func Warn(args ...interface{}) {
	DefaultLogger.Warn(args...)
}
func Warnf(format string, args ...interface{}) {
	DefaultLogger.Warnf(format, args...)
}
func Error(args ...interface{}) {
	DefaultLogger.Error(args...)
}
func Errorf(format string, args ...interface{}) {
	DefaultLogger.Errorf(format, args...)
}
func Panic(args ...interface{}) {
	DefaultLogger.Panic(args...)
}
func Panicf(format string, args ...interface{}) {
	DefaultLogger.Panicf(format, args...)
}
func Fatal(args ...interface{}) {
	DefaultLogger.Fatal(args...)
}
func Fatalf(format string, args ...interface{}) {
	DefaultLogger.Fatalf(format, args...)
}
